package yto.freemarker.springaop.processor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * 自定义的bean的后置处理器
 *
 * 该类在实例化（IOC）和依赖注入（DI）后被调用
 *
 * 默认对每个Bean都处理，想要处理具体的哪个Bean的，依据BeanName来处理具体的Bean
 *
 * @author dongxing
 **/
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("before bean Name--"+beanName);
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("after bean Name--"+beanName);
        return bean;
    }
}
